﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using CoreInmobiliario.Data;

namespace CoreInmobiliario.Business
{
    [DataObject]
    public class Operacion
    {
        public static Operacion GetInstance()
        {
            return new Operacion();
        }

        private static DBDataContext GetDBDataContext()
        {
            Factories.DBDataContextFactory factory = new Factories.DBDataContextFactory();
            return factory.CreateDataContext() as DBDataContext;
        }

        public Data.Operacion GetById(int operacionId)
        {
            Data.Operacion operacion = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    operacion = dataContext.Operacions.FirstOrDefault(o => o.OperacionId.Equals(operacionId));
                }
                catch (Exception ex)
                {

                }
            }
            return operacion;
        }

        public List<Data.Operacion> GetList()
        {
            List<Data.Operacion> list = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    list = dataContext.Operacions.ToList();

                }
                catch (Exception ex)
                {

                }
            }
            return list;
        }
    }
}
